<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['pluginset']=$this->plugin_setting('areasetting');
cfc('core')->checklogin();
$area_agent=$this->get('area_agent',array('mid'=>$_SESSION['uid']));
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('areapage');
	$params=array('storeid'=>$area_agent['storeid']);
	if($isxuni){
		$params['level']=18;
	}
	$return['commission_money']=pdo_getsum('jy_weishop_store_commission',$params,'money');
	$return['commission_total']=pdo_count('jy_weishop_store_commission',$params);
	$levels=array();
	$return['area_types']=$this->area_types;
	for($i=0;$i<3;$i++){
		$level=$i+1;
		$levels[$level]=pdo_count('jy_weishop_store_commission',array('mid'=>$_SESSION['uid'],'type'=>$level+3));
	}
	$return['levels']=$levels;
	$return['list']=array();
	$return['params']=array(
		'level'=>1,
		'page'=>1,
	);
	$return['psize']=20;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('storeid'=>$area_agent['storeid']);
	$level=intval($_RQ['level']);
	if(!$level){
		$level=1;
	}
	$params['type']=$level+3;
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		
	);
	$list=pdo_getlist('jy_weishop_store_commission',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$item['member']=model('core/member')->basic($item['mid']);	
	}
	exi($list);
}
?>